<template>
  <el-form :model="sourceData" ref="formRef" :label-width="'100px'">
    <el-row>
      <el-col :span="6">
        <el-form-item label="订单号">{{ sourceData.orderNum }}</el-form-item>
      </el-col>
      <el-col :span="5">
        <el-form-item label="付款金额"
                      prop="payMoney"
                      :rules="[
                              { required: true, message: '请输入付款金额', trigger: 'blur' },
                              this.$rules.isPosInt('付款金额必须大于0')
                              ]">
          <el-input maxlength="6" show-word-limit clearable placeholder="付款金额" v-model="sourceData.payMoney"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="入账时间"
                      prop="gainTime"
                      :rules="[{ required: true, message: '请选择入账时间', trigger: 'blur' }]">
          <el-date-picker
              class="date"
              v-model="sourceData.gainTime"
              type="date"
              value-format="yyyy-MM-dd HH:mm:ss"
              placeholder="选择开始日期"
          />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="摘要"
                      prop="remark"
                      :rules="[{ required: true, message: '请输入摘要', trigger: 'blur' } ]">
          <el-input show-word-limit placeholder="摘要" v-model="sourceData.remark"/>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
export default {
  name: "item",
  props: {
    datas: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  watch: {
    datas(newValue) {
      this.filterData(newValue)
    }
  },
  data() {
    return {
      sourceData: {
        orderNum: '',
        orderId: '',
        payMoney: '',
        remark: '',
        gainTime: ''
      }
    }
  },
  created() {
    this.filterData(this.datas)
  },
  methods: {
    filterData(data) {
      this.sourceData = Object.assign({}, this.sourceData, data)
    },
    getData() {
      return this.sourceData
    },
    validate() {
      return new Promise(resolve => {
        this.$refs.formRef.validate((valid) => {
          resolve(valid)
        })
      })
    },
  }
}
</script>

<style scoped>

</style>